from threading import Thread
from time import sleep


def func(name):
    for i in range(3):
        print(f"{name}的第{i}次执行")
        sleep(1)


if __name__ == '__main__':
    print('----主线程启动----')
    t1 = Thread(target=func, args=('t1',))
    t2 = Thread(target=func, args=('t2',))
    t1.start()
    t2.start()
    # 注意此处，join不能在各自启动后直接开始执行，必须在两个线程均启动后才能达到并发效果，否则多个线程串行
    t1.join()
    t2.join()
    print('----主线程结束----')